import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        user: {
            uid: '1',
            name: 'zxc',
            profile: 'no time',
            faceUrl: 'https://tva1.sinaimg.cn/large/0081Kckwgy1gkdj64e2scj30p00oy4qp.jpg',

            drinkingTarget: 3000,
            drinkingWater: 0,
            count: 0,
            level: 0,

            lastWeekDrink: [0, 0, 0, 0, 0, 0, 0],
            info: [
                {
                    time: '2020-12-27',
                    drink: 200,
                    count: 1
                }, {
                    time: '2020-12-28',
                    drink: 0,
                    count: 0
                }, {
                    time: '2020-12-29',
                    drink: null,
                    count: null
                }, {
                    time: '2020-12-30',
                    drink: null,
                    count: null
                }, {
                    time: '2020-12-31',
                    drink: null,
                    count: null
                }, {
                    time: '2021-1-1',
                    drink: null,
                    count: null
                }, {
                    time: '2021-1-2',
                    drink: null,
                    count: null
                }],

            cups: [
                {
                    id: 1,
                    cupName: '默认杯子',
                    img: 'https://s3.ax1x.com/2020/12/30/rOHed1.jpg',
                    capacity: 550,
                    drinkWater: 0,
                    intro: '介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧介绍一下它吧',
                    settings: {
                        touchMaxTime: 1000, // 检测长按事件的最长时间
                        touchWaterMaxML: 50, // 点击一次最大可以加多少ml的水
                        touchWaterMinML: 30, // 点击一次至少可以加多少ml的水
                        waterColour: 'rgba(96,161,229,0.4)',
                    }
                }, {
                    id: 2,
                    cupName: '咕噜咕噜用于喝白开水的杯子',
                    img: 'https://s3.ax1x.com/2020/12/30/rOHed1.jpg',
                    capacity: 550,
                    drinkWater: 0,
                    intro: '介绍一下它吧',
                    settings: {
                        touchMaxTime: 1000, // 检测长按事件的最长时间
                        touchWaterMaxML: 120, // 点击一次最大可以加多少ml的水
                        touchWaterMinML: 30, // 点击一次至少可以加多少ml的水
                        waterColour: 'rgba(14,114,214,0.4)',
                        gravity: 1
                    }
                }, {
                    id: 3,
                    cupName: '这个杯子的水是紫色的',
                    img: 'https://s3.ax1x.com/2020/12/30/rOHed1.jpg',
                    capacity: 200,
                    drinkWater: 0,
                    intro: '介绍一下它吧',
                    settings: {
                        touchMaxTime: 1000, // 检测长按事件的最长时间
                        touchWaterMaxML: 130, // 点击一次最大可以加多少ml的水
                        touchWaterMinML: 40, // 点击一次至少可以加多少ml的水
                        waterColour: 'rgba(91,15,109,0.4)',
                        gravity: 0.5,
                        waterValue: 1
                    }
                }, {
                    id: 4,
                    cupName: '这个杯子的名字很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
                    img: 'https://s3.ax1x.com/2020/12/30/rOHed1.jpg',
                    capacity: 1000,
                    drinkWater: 0,
                    intro: '介绍一下它吧',
                    settings: {
                        touchMaxTime: 1000, // 检测长按事件的最长时间
                        touchWaterMaxML: 140, // 点击一次最大可以加多少ml的水
                        touchWaterMinML: 50, // 点击一次至少可以加多少ml的水
                        gravity: 2,
                    }
                }, {
                    id: 5,
                    cupName: '短',
                    img: 'https://s3.ax1x.com/2020/12/30/rOHed1.jpg',
                    capacity: 600,
                    drinkWater: 0,
                    intro: '介绍一下它吧',
                    settings: {
                        touchMaxTime: 1000, // 检测长按事件的最长时间
                        touchWaterMaxML: 300, // 点击一次最大可以加多少ml的水
                        touchWaterMinML: 100, // 点击一次至少可以加多少ml的水
                        gravity: 3
                    }
                }],
        },

        waterInc: 0,// 用于检测打卡的，每1/3就可以打卡一次。打卡后归零

        activeCup: {},
        currentIndex: 0,
        cards: [
            {
                id: 2,
                title: '打卡第一天',
                coverUrl: require('./assets/img/img1.jpg'),
                location: {
                    lat: 'North Lat 36',
                    lng: 'East Lng 97'
                },
                brief: '这里好像可以写一些什么东西，但是字数貌似有限制',
                postcode: 'NO. 0000001',
                level: 4,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/22/rsV4Wn.jpg',
                    name: '小iu'
                },
                pushDate: '2020/12/21',
                content: '这些是你的杯子们。实验表明，喝白开水比喝黑开水更健康。\n' +
                    '            一般正常成年人，每天摄入水份2500-3500mL比较合适，除了每天直接喝的茶水外，一些含水量较多的水果、牛奶制品、液体饮料、活性饮料，包括碳酸饮料，都可以作为摄入液体的指数进行计算。',
                active: false
            },
            {
                id: 1,
                title: '打卡第二天',
                coverUrl: require('./assets/img/img2.jpg'),
                location: {
                    lat: 'North Lat 36',
                    lng: 'East Lng 97'
                },
                brief: '这里好像可以写一些什么东西，但是字数貌似有限制',
                postcode: 'NO. 0000002',
                level: 3,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/22/rsV4Wn.jpg',
                    name: '小iu'
                },
                pushDate: '2020/12/21',
                content: '这些是你的杯子们。实验表明，喝白开水比喝黑开水更健康。\n' +
                    '            一般正常成年人，每天摄入水份2500-3500mL比较合适，除了每天直接喝的茶水外，一些含水量较多的水果、牛奶制品、液体饮料、活性饮料，包括碳酸饮料，都可以作为摄入液体的指数进行计算。',
                active: false
            },
            {
                id: 3,
                title: '我不想喝水',
                coverUrl: require('./assets/img/img3.jpg'),
                location: {
                    lat: 'North Lat 36',
                    lng: 'East Lng 97'
                },
                brief: '她知道这里可以写一些东西，但是不想写',
                postcode: 'NO. 0000003',
                level: 4,
                user: {
                    uid: '3',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: 'iu'
                },
                pushDate: '2020/12/21',
                content: '这些是你的杯子们。实验表明，喝白开水比喝黑开水更健康。\n' +
                    '            一般正常成年人，每天摄入水份2500-3500mL比较合适，除了每天直接喝的茶水外，一些含水量较多的水果、牛奶制品、液体饮料、活性饮料，包括碳酸饮料，都可以作为摄入液体的指数进行计算。',
                active: false
            },
            {
                id: 4,
                title: 'H2O有毒哦',
                coverUrl: require('./assets/img/img4.jpg'),
                location: {
                    lat: 'North Lat 36',
                    lng: 'East Lng 97'
                },
                brief: '她知道这里可以写一些东西，但是不想写',
                postcode: 'NO. 0000004',
                level: 4,
                user: {
                    uid: '3',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: 'iu'
                },
                pushDate: '2020/12/21',
                content: '这些是你的杯子们。实验表明，喝白开水比喝黑开水更健康。\n' +
                    '            一般正常成年人，每天摄入水份2500-3500mL比较合适，除了每天直接喝的茶水外，一些含水量较多的水果、牛奶制品、液体饮料、活性饮料，包括碳酸饮料，都可以作为摄入液体的指数进行计算。',
                active: false
            }
        ],

        followList: ['2'],
        likeList: [10001],

        pushList: [
            {
                id: 10001,
                user: {
                    uid: '1',
                    faceUrl: 'https://tva1.sinaimg.cn/large/0081Kckwgy1gkdj64e2scj30p00oy4qp.jpg',
                    name: "zxc"
                },
                date: "2021/1/3 上午1:32:16",
                content: "这里是关于每次喝完一杯水的内容"
            },
            {
                id: 10002,
                user: {
                    uid: '1',
                    faceUrl: 'https://tva1.sinaimg.cn/large/0081Kckwgy1gkdj64e2scj30p00oy4qp.jpg',
                    name: "zxc"
                },

                date: "2021/1/3 上午1:32:16",
                content: "或许可以不用写"
            },
            {
                id: 10003,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: "iu"
                },
                date: "2021/1/3 上午1:32:16",
                content: "所以可以空着，就像下面一样"
            },
            {
                id: 10004,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: "iu"
                },

                date: "2021/1/3 上午1:32:16",
                content: null
            },
            {
                id: 10005,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: "iu"
                },
                date: "2021/1/3 上午1:32:16",
                content: "所以可以空着，就像上面一样"
            },
            {
                id: 10006,
                user: {
                    uid: '2',
                    faceUrl: 'https://s3.ax1x.com/2020/12/21/r0jJhj.jpg',
                    name: "iu"
                },
                date: "2021/1/3 上午1:32:16",
                content: null
            },
        ],

        planetData: {
            planet: null,
            trees: [],
            water: [],
            clouds: [],
            settings: {
                smooth: true, // 是否开启平滑点击
                touchMaxTime: 1000, // 检测长按事件的最长时间
                touchWaterMaxML: 100, // 点击一次最大可以加多少ml的水
                touchWaterMinML: 20, // 点击一次至少可以加多少ml的水
            }
        },


        /* =====  global settings  ===== */
        globalSettings: {
            // 默认颜色 rgb(247, 247, 252)
            smooth: {
                info: {
                    icon: 'icon-pinghua',
                    name: '平滑点击',
                    intro: '开启时：生成最小的水滴是随机的，但是也不会超过最小时。\n不开启时：生成的水滴是固定的最小值。',
                    color: 'rgb(108, 191, 229)',
                    hasMore: false // 默认是false
                },
                value: true
            },
            hintPunch: {
                info: {
                    icon: 'icon-tishi',
                    name: '打卡提示',
                    intro: '开启时首页的喝水百分比小球会在可以打卡时跳动。',
                    color: 'rgb(248, 206, 104)',
                    hasMore: false
                },
                value: true
            },
            sharePunch: {
                info: {
                    icon: 'icon-shuibeiheshuiwater',
                    intro: '分享你的打卡信息。',
                    name: '打卡分享',
                    color: 'rgb(224,66,89)',
                    hasMore: true
                },
                value: true
            },
            shareCard: {
                info: {
                    icon: 'icon-fenxiang',
                    intro: '分享你发布的卡片信息。',
                    name: '卡片分享',
                    color: 'rgb(224,66,89)',
                    hasMore: true
                },
                value: true
            }
        },


        /* =====  system  ===== */
        homeActive: -1,
        selected: null,
        unselect: null,
        notify: {
            msg: 'notify hi 🙋',
            action: true,
            font: 36,
            duration: 1000,
            height: '100px',
            success: null,
            snooze: null
        },
        notifyShow: false,
        notifySuccess: false,

    },
    mutations: {
        addPushList(state, push) {
            state.waterInc = 0;
            state.pushList.unshift(push);
        },
        changeCup(state, cup) {
            state.activeCup = cup;
        },
        setPlanet(state, planetData) {
            state.planetData.planet = planetData.planet;
            state.planetData.trees = planetData.trees;
            state.planetData.water = planetData.water;
        },
        setPlanetSettings(state, settings) {
            state.planetData.settings = settings;
        },
        activateNotify(state, show) {
            state.notifyShow = show;
        },
        successNotify(state, op) {
            state.notifySuccess = op;
        },
        notify(state, notify) {
            state.notifySuccess = false;
            state.notify = notify;
            state.notifyShow = true;
        },
        setHomeActive(state, i) {
            state.homeActive = i;
        },
        canDrinkWater(state, canDrink) {
            state.user.drinkingWater += canDrink.v;
            state.user.info[new Date().getDay()].drink += canDrink.v;
            state.waterInc += canDrink.v;
            if (canDrink.do) {
                state.user.count++;
                state.user.info[new Date().getDay()].count++;
            }
        },
        toFollow(state, uid) {
            state.followList.push(uid);
        },
        toLike(state, id) {
            state.likeList.push(id);
        },
        toggleCard(state, {card}) {
            if (state.selected && state.selected.card === card) {
                return
            }
            card.active = !card.active
        },
        nextCard(state) {
            if (state.selected) {
                return
            }
            state.cards.forEach(card => {
                card.active = false
            })
            if (state.currentIndex < state.cards.length - 1) {
                state.currentIndex++
            }
        },
        prevCard(state) {
            if (state.selected) {
                return
            }
            state.cards.forEach(card => {
                card.active = false
            })
            if (state.currentIndex > 0) {
                state.currentIndex--
            }
        },
        selectCard(state, selected) {
            state.unselect = null
            state.selected = selected
        },
        unselectCard(state) {
            state.unselect = state.selected
            state.selected = null
        }
    },
    actions: {}
})
